package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.zx.kitchen.index.common.entity.PurchaseData;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.PurchaseModelImpl;
import com.zx.kitchen.index.common.mvp.view.PurchaseView;

import java.util.List;

/**
 * Created by Administrator on 2017/3/3.
 */

public class PurchasePresenter implements OnResultListener {

    private PurchaseView purchaseView;
    private Context context;
    private PurchaseModelImpl purchaseModel;

    public PurchasePresenter(PurchaseView purchaseView, Context context) {
        this.purchaseView = purchaseView;
        this.context = context;
        purchaseModel = new PurchaseModelImpl();
    }

    public void getFromNet(int p, String start_time, String end_time) {
        purchaseModel.getFromNet(0, context, p, start_time, end_time, this, null);
    }

    @Override
    public void onSuccess(int requestCode, String str) {
        //解析JSON数据
        PurchaseData list = purchaseModel.asyncJson(str);
        //显示到界面上
        purchaseView.onSuccess(list);
    }


    @Override
    public void onFailure(int requestCode, String str) {
        purchaseView.onFail(str);

    }
}
